#include<bits/stdc++.h>
using namespace std;

typedef pair<string, string> pss;

template<typename T> 
struct Linknode {
	T value;
	int pos;                   //¼ÇÂ¼Á´±íÖÐµÄÃ¿Ò»¸öÔªËØÔÚËùÔÚÁ´±íÖÐµÄ¾ßÌåÎ»ÖÃ·½±ãÖ®ºó½øÐÐ¶þ·Ö²éÕÒ 
	Linknode* next;
	
	Linknode(T value, int position) {  //Á½¸ö²ÎÊýµÄ¹¹Ôìº¯Êý 
		this->value = value;
		this->next = nullptr;
		this->pos = position;
	}
	
	Linknode() : next(nullptr) {}
};

class Linklist {
	private:
		Linknode<pss> *head;
		
		Linknode<pss> *get(int target) {
			auto *cur = head->next;
			while(cur) {
				if(cur->pos == target) return cur;
				cur = cur->next;
			}
			return nullptr;
		}
		
		Linknode<pss> *BinarySearch(string key) {
			int l = 0, r = size();
			while(l < r) {
				int mid = l + r + 1 >> 1;
				if(get(mid)->value.first <= key) l = mid;
				else r = mid - 1;
			}
			if(!l) return head;
			auto *res = get(l);
			return res;
		}
		
	public:
		Linklist() { head = new Linknode<pss>(make_pair("0", "0"), 0); }
		
		void printinformation() {
			auto *cur = head->next;
			while(cur) {
				cout << "[Ó¢ÎÄ = " << cur->value.first << ", ÖÐÎÄ = " << cur->value.second << "]" << '\n';
				cur = cur->next;
			}
		}
		
		int size() {
			auto *cur = head->next;
			int cnt = 0;
			while(cur) {
				cur = cur->next;
				cnt++;
			}
			return cnt;
		}
		
		void insertNode(string key, string value) {
			auto *cur = BinarySearch(key);
			Linknode<pss> *p = new Linknode<pss>(make_pair(key, value), cur->pos + 1);
			p->next = cur->next;
			cur->next = p;
			//ÓÉÓÚÌí¼ÓÁËÒ»¸öÔªËØ£¬Òò´ËÒª¶ÔÖ®ºóµÄpos¶¼½øÐÐ+1²Ù×÷ 
			p = p->next;
			while(p) {
				p->pos++;
				p = p->next;
			}
		}
		
		void deleteNode(string key) {
			auto *cur = BinarySearch(key);
			if(cur->value.first == "0")
				cout << "²¢Î´ÕÒµ½¸Ãµ¥´Ê" << '\n';
			if(!cur->next) {
				cur = nullptr;
				delete cur;	
			} else {
				cur->value = cur->next->value;
				cur->next = cur->next->next;
				delete cur->next; 
			}
		}
		
		void buildLinklist() {
			string key, value;
			while(cin >> key >> value) {
				if(key == "zoology") break ;
				insertNode(key, value);
				if(key == "zoology") break ;
			}
		}
		
		void clearLinklist() {
			auto *cur = head;
			while(cur) {
				auto *p = cur;
				cur = cur->next;
				delete p;
			}
		}
		
		void getValue(string s) {
			auto *cur = BinarySearch(s);
			if(cur->value.first != s) cout << "ÎÞ·¢ÕÒµ½¸Ãµ¥´Ê" << '\n';
			else 
				cout << "[Ó¢ÎÄ = " << cur->value.first << ", ÖÐÎÄ = " << cur->value.second << "]" << '\n';
		}
};

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	Linklist test;
	test.buildLinklist();
	test.printinformation(); 
	test.clearLinklist();
}
